#include <unistd.h>
#include <string.h>
#include <errno.h>

#include <icommon.h>
#ifdef DMALLOC
#include <imp/dmalloc.h>
#endif
int c_save_to_file(int fd, void *buf, int size)
{
	int ret = 0;
	if ((ret = write(fd, buf, size)) != size) {
		c_log(C_LOG_ERROR, "%s buf:%p size:%d failed:%s\n", __func__, buf, size, ret < 0 ? strerror(errno) : "");
		return -1;
	}

	return ret;
}
